package net.acoinWork.demo.dao.impl;

import net.acoinWork.demo.dao.DemoDao;
import net.acoinWork.demo.dao.MockDao;
import net.acoinWork.demo.pojo.DemoPerson;
import net.acoinWork.dynRender.organize.Organizer;

import java.util.*;

/**
 * 演示dao
 *
 * @author xusk
 * @Date: 15/12/31 下午3:58
 */
public class DemoDaoFreemarkerImpl extends MockDao implements DemoDao {
    private static final Organizer<Map> organizer =
            new Organizer<Map>("/demoDaoFreemarker.xml");

    /**
     * 演示一个dao的方法如何使用
     *
     * @param list
     * @return
     */
    @Override
    public List<Object> getListByAges(List<DemoPerson> list) {
        final Date o = new Date();
        Map<String, Object> map = new HashMap<String, Object>();
        List<Integer> ageList = new ArrayList<Integer>();
        for (DemoPerson dp : list) {
            ageList.add(dp.getAge());
        }
        map.put("list", ageList);
        final List<Object> result = query(organizer.getResById("getListByAges", map));
        System.out.println("timeCost:" + (new Date().getTime() - o.getTime()) + "ms");
        return result;
    }

}
